package com.itheima.reggie.controller;

import com.itheima.reggie.utils.FileUploader;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("minio")
public class MinioController {

    @Autowired
    private FileUploader fileUploader;

    @PostMapping("upload")
    @ResponseBody
    public String upload(MultipartFile file) throws IOException {
        try {
            fileUploader.upload(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "success";
    }
}